package n2392;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	static int arr[][]=new int[401][3];
	
	static boolean v[]=new boolean[40001];
	
	static int K;
	
	static int solve()
	{
		Arrays.sort(arr, 0,K,new Comparator<int []>(){
			public int compare(int[] o1, int[] o2) {
				return o1[1]-o2[1];
			}
		});
		
//		for(int i=0;i<K;i++)
//		{
//			System.out.println(arr[i][0]+" "+arr[i][1]+" "+arr[i][2]);
//		}
		
		v[0]=true;
		int max=0;
		for(int i=0;i<K;i++)
		{
			for(int j=max;j>=0;j--)
			{
				if(v[j])
				{
					int tmp=j;
					for(int k=0;k<arr[i][2];k++)
					{
						tmp+=arr[i][0];
						if(tmp>arr[i][1])break;
						v[tmp]=true;
						if(max<tmp)max=tmp;
					}
				}
			}
		}
		return max;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
		K=Integer.parseInt(bf.readLine());
		for(int i=0;i<K;i++)
		{
			StringTokenizer st=new StringTokenizer(bf.readLine());
			arr[i][0]=Integer.parseInt(st.nextToken());
			arr[i][1]=Integer.parseInt(st.nextToken());
			arr[i][2]=Integer.parseInt(st.nextToken());
		}
		System.out.println(solve());
	}

}
